home *** CD-ROM | disk | FTP | other *** search
- Path: news.larc.nasa.gov!amiga-request
- From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v91i123: bmake 0.6 - automate recompiling multiple source files, Part01/03
- Reply-To: ENG BENNY <engb@ecf.toronto.edu>
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga.v91i123@ab20.larc.nasa.gov>
- Date: 04 Jul 91 16:38:42 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga.misc
-
- Submitted-by: ENG BENNY <engb@ecf.toronto.edu>
- Posting-number: Volume 91, Issue 123
- Archive-name: utilities/bmake-0.6/part01
-
- [ binaries to appear in comp.binaries.amiga ...tad ]
-
- This program requires Amiga OS 2.0 or higher to run. Run the program with
- the argument `?' to see its usage, or ``-h'' to get more descriptive help
- on acceptable command line arguments.
-
- Make is a programming utility used to automate the process of recompiling
- multiple interdependent source files into an output file, which is called
- the goal. The rules for making the goal are explicitly stated in an input
- file called the Makefile, and implicitly determined from builtin inference
- rules. Normally, the Makefile for a goal is written so that the only thing
- that needs to be done to recompile newly modified source files is to run
- the Make program.
-
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 3)."
- # Contents: Makefile TEST-Makefile ben ben/basename.c ben/makefile
- # ben/scdir.c ben/system.c builtin.c builtins.make compiling
- # depend.c depend.h dumprules.c history include include/scdir.h
- # known-bugs lists.c log.c macro.c main.c make.h param.c parsing.c
- # rawcon.c readme recipe.c snode.c touch.c version.c wishlist
- # Wrapped by tadguy@ab20 on Thu Jul 4 12:38:40 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(919 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- X# Makefile for Make
- X# (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X#
- X#
- X#OPTIONS :=
- X# -DMAXLINE=1024 sets the maximum line length to 1024
- X# -DMAXSUFFIX=16 sets the maximum suffix length to 16
- X# -DMAXPATHNAME=108 sets the maximum length of a path name to 108
- X# -DMAX_MACRONAME=512 to overide internal default of 256
- X# -DFNCALLS=0 to disable function calls
- XOPTIONS :=
- X# -gs enables dynamic stack growth
- X# -s enables symbolic information
- XCC := dcc
- XCFLAGS := -r -ms -proto $(OPTIONS)
- XLIBS := -lben
- X
- XDHOBJS := main.o depend.o input.o dumprules.o make.o builtin.o recipe.o \
- X macro.o expand.o fncall.o read.o
- XOBJS = lists.o snode.o param.o touch.o log.o parsing.o $(DHOBJS)
- X
- XVERS := version.o
- X
- Xall: bmake
- X
- Xbmake: $(VERS)
- X $(CC) $(CFLAGS) -o $@ $(OBJS) $(VERS) $(LIBS)
- X -delete make.log
- X
- X$(VERS): $(OBJS)
- X
- X$(OBJS): make.h
- X
- X$(DHOBJS): depend.h
- X
- Xclean:
- X -delete $(OBJS) $(VERS) make.log
- X
- Xinstall:
- X copy bmake sys:bin/make
- X
- END_OF_FILE
- if test 919 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'TEST-Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'TEST-Makefile'\"
- else
- echo shar: Extracting \"'TEST-Makefile'\" \(2077 characters\)
- sed "s/^X//" >'TEST-Makefile' <<'END_OF_FILE'
- X# Just for testing
- X#
- X# To debug, run the resulting make utility with the following arguments
- X# bmake -a -d -n -v9 +l -f TEST-Makefile
- X# the log file make.log will contain a detailed account of what the
- X# program attempted to do.
- X#
- X
- X.jj.k: ; echo "jj to k suffix rule"
- X
- X.SUFFIXES: .jj .k
- X
- Xaaaaaa = 1
- XA = aaa
- XB := $(A)$(A)
- XC := $($(B))
- X
- X# This one is cool.
- XSRCS := $(wildcard #?.c)
- XOBJS := $(subst .c,.o,$(SRCS))
- XLIBS := -lben
- X
- X# Test some of the function calls
- XSSRC := $(filter s%,$(SRCS))
- XWILD := $(wildcard #?.c)
- XBASE := $(basename $(WILD))
- XASUF := $(addsuffix .x,$(BASE))
- XAPRE := $(addprefix foo-,$(BASE))
- XNAPRE := $(words $(APRE))
- X
- X# test nested conditionals
- Xifndef (DOIT)
- Xifdef (undefined)
- X undefined := $(strip $(undefined))
- Xelse
- X undefined := undefined
- Xendif
- X DOIT = $(undefined)
- Xendif
- X
- Xdoodah:
- X @echo "$$ $C $$"
- X @echo "SOURCES:"
- X @echo "$(SRCS)"
- X @echo ""
- X @echo "OBJECTS:"
- X @echo "$(OBJS)"
- X @echo ""
- X @echo "SOURCES starting in s:"
- X @echo "$(SSRC)"
- X @echo ""
- X @echo "replacing ee with EE:"
- X @echo "$(subst ee,EE,feet on the street)"
- X @echo ""
- X @echo "$$(wildcard #?.c)"
- X @echo "$(WILD)"
- X @echo ""
- X @echo "basenames of the above filenames"
- X @echo "$(BASE)"
- X @echo ""
- X @echo "add suffix .x to the above basenames"
- X @echo "$(ASUF)"
- X @echo ""
- X @echo "add prefix foo- to the above basenames"
- X @echo "$(APRE)"
- X @echo "find the first word in the above foo-list"
- X @echo "$(firstword $(APRE))
- X @echo "find the last word in the above foo-list"
- X @echo "$(word $(NAPRE),$(APRE))
- X
- X# test a conditional
- Xif eq($(DOIT),yes)
- X @echo "DOIT=yes; hurray!"
- Xelse
- X @echo "DOIT=$(DOIT)"
- Xendif
- X
- Xfinger := my toe hurts
- Xbleh:
- X echo "$(ugh) $(findstring hello,my hello) $(strip $(finger))"
- X
- XMONSTER := a.b a.c b.b b.c
- XBEES := $(filter %.b,$(MONSTER))
- XCEES := $(filter %.c,$(MONSTER))
- XNOTB := $(filter-out %.b,$(MONSTER))
- XNOTC := $(filter-out %.c,$(MONSTER))
- X
- X# Now for a real-live generic rule that will make a.out
- X# from any .c files in your current directory! Neat huh?
- X# Just change a.out to your favourite file name for the binary.
- Xa.out: $(OBJS)
- X $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS)
- END_OF_FILE
- if test 2077 -ne `wc -c <'TEST-Makefile'`; then
- echo shar: \"'TEST-Makefile'\" unpacked with wrong size!
- fi
- # end of 'TEST-Makefile'
- fi
- if test ! -d 'ben' ; then
- echo shar: Creating directory \"'ben'\"
- mkdir 'ben'
- fi
- if test -f 'ben/basename.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ben/basename.c'\"
- else
- echo shar: Extracting \"'ben/basename.c'\" \(352 characters\)
- sed "s/^X//" >'ben/basename.c' <<'END_OF_FILE'
- X/* basename.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#define AMIGA
- X
- Xchar *
- Xbasename( char *pathname )
- X{
- X char *ptr, *filename;
- X
- X for( filename = ptr = pathname; *ptr; ptr++ )
- X if( *ptr == '/' /* directory delimiter */
- X#ifdef AMIGA
- X || *ptr == ':' /* device delimiter */
- X#endif
- X ) filename = ptr+1;
- X return( filename );
- X}
- X
- END_OF_FILE
- if test 352 -ne `wc -c <'ben/basename.c'`; then
- echo shar: \"'ben/basename.c'\" unpacked with wrong size!
- fi
- # end of 'ben/basename.c'
- fi
- if test -f 'ben/makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ben/makefile'\"
- else
- echo shar: Extracting \"'ben/makefile'\" \(228 characters\)
- sed "s/^X//" >'ben/makefile' <<'END_OF_FILE'
- X# Makefile for ben.lib
- X# (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X#
- X
- XCC = dcc
- XAS = dcc
- XCFLAGS = -2.0 -ms -r -proto
- X
- XOBJ = scdir.o basename.o system.o
- X
- Xben.lib : $(OBJ)
- X join $(OBJ) as $@
- X
- Xinstall:
- X copy ben.lib dlib:
- X
- END_OF_FILE
- if test 228 -ne `wc -c <'ben/makefile'`; then
- echo shar: \"'ben/makefile'\" unpacked with wrong size!
- fi
- # end of 'ben/makefile'
- fi
- if test -f 'ben/scdir.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ben/scdir.c'\"
- else
- echo shar: Extracting \"'ben/scdir.c'\" \(3381 characters\)
- sed "s/^X//" >'ben/scdir.c' <<'END_OF_FILE'
- X/* scan directory for filenames matching wildcard
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X * scdir() must be called until it returns NULL
- X * or else scdir_abort() must be called to free up resources
- X */
- X
- X#include <exec/types.h>
- X#include <exec/execbase.h>
- X#include <dos/dos.h>
- X#include <dos/dosextens.h>
- X#include <dos/dosasl.h>
- X#include <clib/dos_protos.h>
- X#include <string.h>
- X
- Xstatic struct AnchorPath AnPath;
- Xstatic char *oldwild = NULL;
- Xstatic LONG failure = 0;
- Xstatic char *result = NULL;
- X
- X#include <stdlib.h>
- X
- Xvoid
- Xscdir_abort( void )
- X{
- X if( result ) {
- X free( result ); result = NULL;
- X }
- X if( oldwild ) {
- X free( oldwild ); oldwild = NULL;
- X if( !failure ) MatchEnd( &AnPath );
- X failure = -1;
- X }
- X}
- X
- X#if 0
- X/* uncomment this routine if extern basename() does not return a
- X * pointer in the same string as pathname
- X */
- Xstatic char *
- Xbasename( char *pathname )
- X{
- X char *ptr, *filename;
- X
- X for( filename = ptr = pathname; *ptr; ptr++ )
- X if( *ptr == '/' /* directory delimiter */
- X || *ptr == ':' /* device delimiter */
- X ) filename = ptr+1;
- X return( filename );
- X}
- X#else
- Xextern char *basename( char *);
- X#endif
- X
- Xstatic char *
- Xscdir_result( char *wild, char *name )
- X{
- X long size;
- X
- X if( result ) {
- X free( result ); result = NULL;
- X }
- X if( name ) {
- X size = strlen( wild ) + strlen( name ) + 1;
- X if( result = (char *)malloc( size )) {
- X strcpy( result, wild );
- X strcpy( basename( result ), name );
- X return( result );
- X }
- X MatchEnd( &AnPath );
- X }
- X return( NULL );
- X}
- X
- X/*
- X* NAME
- X* scdir -- scans a directory for filenames matching Amiga wildcard
- X*
- X* SYNOPSIS
- X* filename = scdir( wildcard )
- X*
- X* char *scdir( const char *scdir )
- X*
- X* FUNCTION
- X* This function returns a single filename that matches the AmigaDOS
- X* wildcard. Consecutive calls with the same wildcard will result
- X* in the next filename that matches the wildcard. This function
- X* should be called with the same wildcard until all matching
- X* filenames are exhausted, at which time NULL is returned.
- X*
- X* INPUTS
- X* wildcard - the full pathname with wildcard to be matched
- X*
- X* RESULT
- X*
- X* filename - the next filename matching the wildcard or
- X* NULL if there are no more matches found or
- X* NULL if an error occurred
- X*
- X* BUGS
- X* Resources are not properly freed if scdir_abort() is never called
- X* or scdir() is not called until a NULL is returned. That is why
- X* if scdir() is used, the caller should perform an
- X* atexit(scdir_abort), to ensure that resources are always freed.
- X*
- X* SEE ALSO
- X* scdir_abort()
- X*
- X*/
- X
- Xchar *
- Xscdir( const char *wild )
- X{
- X int diff = 0;
- X
- X if( oldwild ) {
- X diff = strcmp( oldwild, wild );
- X if( !diff && failure ) return( scdir_result( wild, NULL ));
- X }
- X if( !oldwild || diff ) {
- X if( oldwild ) free( oldwild );
- X oldwild = strdup( wild );
- X
- X AnPath.ap_BreakBits = SIGBREAKF_CTRL_C; /* Break on these bits */
- X
- X failure = MatchFirst( wild, &AnPath);
- X
- X if( !failure && AnPath.ap_Info.fib_DirEntryType <= 0 ) {
- X return( scdir_result( wild, AnPath.ap_Info.fib_FileName ));
- X }
- X }
- X
- X /* same wildcard as before */
- X while( !failure ) {
- X if( failure = MatchNext( &AnPath )) break;
- X if( AnPath.ap_Info.fib_DirEntryType <= 0 ) {
- X return( scdir_result( wild, AnPath.ap_Info.fib_FileName ));
- X }
- X }
- X /* failure */
- X /* This absolutely, positively must be called, all of the time. */
- X MatchEnd( &AnPath );
- X return( scdir_result( wild, NULL ));
- X}
- X
- END_OF_FILE
- if test 3381 -ne `wc -c <'ben/scdir.c'`; then
- echo shar: \"'ben/scdir.c'\" unpacked with wrong size!
- fi
- # end of 'ben/scdir.c'
- fi
- if test -f 'ben/system.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ben/system.c'\"
- else
- echo shar: Extracting \"'ben/system.c'\" \(1265 characters\)
- sed "s/^X//" >'ben/system.c' <<'END_OF_FILE'
- X/* system.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X */
- X
- X#include <exec/types.h>
- X#include <exec/libraries.h>
- X#include <dos/dos.h>
- X#include <dos/dosextens.h>
- X#include <dos/dostags.h>
- X
- X#include <lib/misc.h>
- X#include <clib/exec_protos.h>
- X#include <clib/dos_protos.h>
- X
- X#include <stdio.h>
- X#include <stdlib.h>
- X
- X#define BTOC(bptr,ctype) ((ctype *)((long)bptr << 2))
- X#define CTOB(ptr) ((long)(ptr) >> 2)
- X
- X/* Synchronous external command (wait for return)
- X * Uses your Input/Output unless you supply other handle
- X * Result will be return code of the command, unless the System() call
- X * itself fails, in which case the result will be -1
- X */
- Xlong
- XdoCommand( char *command, BPTR other )
- X{
- X struct TagItem stags[3];
- X
- X stags[0].ti_Tag = SYS_Input;
- X stags[0].ti_Data = other ? other : Input();
- X stags[1].ti_Tag = SYS_Output;
- X stags[1].ti_Data = other ? 0L : Output();
- X stags[2].ti_Tag = TAG_DONE;
- X return( System( command, stags ));
- X}
- X
- Xlong
- Xxsystem( char *cmd )
- X{
- X long errcode = -1L;
- X char *s;
- X int sflag = 1;
- X
- X if( s = getenv( "SYSTEM" ))
- X sflag = (*s == 'n') ? 0 : 1;
- X
- X if( sflag ) {
- X errcode = doCommand( cmd, 0L );
- X }
- X else {
- X long r;
- X r = Execute( cmd, (BPTR)0L, Output());
- X /* if( r == -1L ) */
- X errcode = IoErr();
- X }
- X return errcode;
- X}
- END_OF_FILE
- if test 1265 -ne `wc -c <'ben/system.c'`; then
- echo shar: \"'ben/system.c'\" unpacked with wrong size!
- fi
- # end of 'ben/system.c'
- fi
- if test -f 'builtin.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'builtin.c'\"
- else
- echo shar: Extracting \"'builtin.c'\" \(1855 characters\)
- sed "s/^X//" >'builtin.c' <<'END_OF_FILE'
- X/* builtin.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <fcntl.h>
- X#include <clib/exec_protos.h>
- X
- X#include "make.h"
- X#include "depend.h"
- X
- Xextern void NewList( struct List *);
- X
- X/* creates a new BUILTIN rule (of any type)
- X * accepts optional command lines as arguments, ending in a NULL
- X * returns the first target created
- X */
- Xstatic struct target *
- Xnew_targetline( char *tline, ... )
- X{
- X va_list argptr;
- X struct List cmdList;
- X struct target *targ;
- X struct command *cmd;
- X char *nextcmd;
- X
- X NewList( &cmdList );
- X va_start( argptr, tline );
- X while( nextcmd = va_arg( argptr, char *)) {
- X cmd = new_command( nextcmd );
- X if( !cmd ) break;
- X AddTail( &cmdList, &cmd->node );
- X }
- X
- X targ = process_targetline( tline, &cmdList, 1 );
- X if( !targ ) delete_commandlist( &cmdList );
- X va_end( argptr );
- X return( targ );
- X}
- X
- Xint
- Xinput_builtins( void )
- X{
- X static char *name_list[] = {
- X "builtins.make",
- X "S:builtins.make",
- X NULL
- X };
- X char *filename;
- X int i = 0;
- X
- X while( filename = name_list[ i++ ] ) {
- X if( !access( filename, 0 )) { /* file exists */
- X if( input_makefile( filename, 1 )) return( 1 );
- X }
- X }
- X return( 0 );
- X}
- X
- Xint
- Xinit_builtins( void )
- X{
- X struct target *targ;
- X
- X if( Param.no_builtins ) return( 0 );
- X
- X set_macro( "CC", "dcc" );
- X set_macro( "AS", "dcc" );
- X set_macro( "CFLAGS", "-proto" );
- X
- X targ = new_targetline( ".a:", NULL ); /* no commands for a files */
- X targ = new_targetline( ".c:", NULL ); /* no commands for c files */
- X targ = new_targetline( ".h:", NULL ); /* no commands for c headers */
- X targ = new_targetline( ".i:", NULL ); /* no commands for asm headers */
- X
- X targ = new_targetline( ".c.o:", "$(CC) -c $(CFLAGS) -o $@ $<", NULL );
- X targ = new_targetline( ".a.o:", "$(AS) -c $(AFLAGS) -o $@ $<", NULL );
- X
- X targ = new_targetline( ".SUFFIXES: .i .h .a .c .o" );
- X
- X if( input_builtins()) return( 1 );
- X
- X return( 0 );
- X}
- X
- END_OF_FILE
- if test 1855 -ne `wc -c <'builtin.c'`; then
- echo shar: \"'builtin.c'\" unpacked with wrong size!
- fi
- # end of 'builtin.c'
- fi
- if test -f 'builtins.make' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'builtins.make'\"
- else
- echo shar: Extracting \"'builtins.make'\" \(226 characters\)
- sed "s/^X//" >'builtins.make' <<'END_OF_FILE'
- X# builtins.make
- X# (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X#
- X# example builtins.make file that defines some builtin rules
- X
- Xclean:
- X echo "clean"
- X
- Xinstall:
- X echo "install"
- X
- Xshar:
- X echo "shar"
- X
- Xlove:
- X @echo " not war!"
- END_OF_FILE
- if test 226 -ne `wc -c <'builtins.make'`; then
- echo shar: \"'builtins.make'\" unpacked with wrong size!
- fi
- # end of 'builtins.make'
- fi
- if test -f 'compiling' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'compiling'\"
- else
- echo shar: Extracting \"'compiling'\" \(3099 characters\)
- sed "s/^X//" >'compiling' <<'END_OF_FILE'
- X
- X Documentation for Compiling
- X Copyright (c) 1991 by Ben Eng
- X
- X
- XHOW TO MAKE
- X
- XThe source code for this program was written for the DICE C compiler,
- Xversion 2.06.22, by Matthew Dillon. The tab size is set to 4. You will
- Xrequire the 2.0 Amiga include files from CATS of Commodore-Amiga to compile
- Xthis program. The source code should compile under any ANSI C compiler for
- Xthe Amiga, but I wouldn't bet on it.
- X
- XIf the executable, ``bmake'', needs to be recompiled then the following
- Xprocedure should be used.
- X
- XFirst, the ``include/scdir.h'' header file should be copied to a directory
- Xin the include path for your compiler. The compiler should be set up to
- Xcompile using the Amiga OS 2.0 (or later) include files.
- X
- XThe link library ``ben.lib'' needs to be made first. Change your directory
- Xto the ``ben'' directory and type ``make'' (or ``bmake'' if that is
- Xavailable to you). If all goes well, then the ``ben.lib'' library will be
- Xcreated; it should be moved to the library search path for your compiler,
- Xso that the linker will be able to find it.
- X
- XChange your directory to the main source directory for the make utility and
- Xtype ``make'' or ``bmake'' to create the binary executable file ``bmake''.
- XThis file can be renamed to the standard ``make'', and placed in the
- Xcommand search path for convenience.
- X
- X
- XPARAMETERS
- X
- XFNCALLS = (1 default) non-zero if function calls are activated
- X
- X If function calls are recognized, this parameter should be defined
- X to be non-zero. Disabling function calls will make the executable
- X somewhat smaller, and memory requirements will be lower.
- X
- XMAXLINE = (1024 default) the maximum number of characters allowed per line
- X
- X This parameter limits the maximum size of a line that can be read from
- X a Makefile, the maximum size of a line that can be assigned to a
- X variable, and the maximum size of a macro expansion. Effectively,
- X MAXLINE is the upper limit on anything manipulated by the Make program.
- X Lines of this size are declared in static storage (input.c) and
- X dynamically (macro.c, etc.).
- X
- XMAXSUFFIX = (16 default) the maximum number of characters in a suffix
- X
- X This parameter limits the maximum size of filename extensions
- X recognized by the Make program. This affects suffix rules and other
- X operations that operating on suffixes. Suffixes are allocated on
- X the stack and dynamically in this fixed size.
- X
- XMAX_MACRONAME = (256 default) the maximum number of characters in a name
- X
- X This parameter limits the size of a macro name.
- X
- XMAXPATHNAME = (108 default) the maximum number of characters in a pathname
- X
- X This parameter limits the size of a pathname that can be used to
- X resolve suffix rules. Dynamically allocated.
- X
- X
- XOPTIONS
- X
- XIn the Makefile, the -gs option can added to CFLAGS to enable DICE's
- Xdynamic stack code. It makes the program grow in size by a couple of
- Xkilobytes, and it slows down execution by a few milliseconds, but it does
- Xmake it safe to run the Make program on a huge Makefile that makes
- Xextensive use of recursive macros and rules, without having to worry about
- Xoverflowing the stack.
- X
- END_OF_FILE
- if test 3099 -ne `wc -c <'compiling'`; then
- echo shar: \"'compiling'\" unpacked with wrong size!
- fi
- # end of 'compiling'
- fi
- if test -f 'depend.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'depend.c'\"
- else
- echo shar: Extracting \"'depend.c'\" \(3984 characters\)
- sed "s/^X//" >'depend.c' <<'END_OF_FILE'
- X/* depend.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <clib/exec_protos.h>
- X
- X#include "make.h"
- X#include "depend.h"
- X
- Xstruct target *
- Xfind_target( char *targetname )
- X{
- X struct target *targ = NULL;
- X
- X for( struct target *ln = Global.targetlist.lh_Head; ln->node.ln_Succ;
- X ln = ln->node.ln_Succ ) {
- X if( !strcmp( targetname, ln->name )) {
- X targ = ln;
- X break;
- X }
- X }
- X
- X return( targ );
- X}
- X
- Xstruct target *
- Xnew_target( char *targetname )
- X{
- X long size;
- X struct target *new = NULL;
- X
- X if( targetname && *targetname && !( new = find_target( targetname ))) {
- X size = sizeof(struct target) + strlen( targetname );
- X new = (struct target *)malloc( size );
- X if( new ) {
- X NewList( &new->dependlist );
- X NewList( &new->commandlist );
- X new->alternate = NULL;
- X new->mtime = 0L;
- X new->flags = 0L;
- X if( targetname ) strcpy( new->name, targetname );
- X else *targetname = (char)0;
- X }
- X }
- X return( new );
- X}
- X
- Xint
- Xdelete_target( struct target *targ )
- X{
- X free( targ );
- X return( 0 );
- X}
- X
- Xvoid
- Xdelete_targetlist( struct List *list )
- X{
- X for_list( list, delete_target );
- X NewList( list );
- X}
- X
- Xstruct depend *
- Xnew_depend( char *dependname )
- X{
- X struct depend *new = NULL;
- X long size;
- X
- X if( dependname ) {
- X size = sizeof(struct depend) + strlen( dependname );
- X if( new = (struct depend *)malloc( size )) {
- X strcpy( new->name, dependname );
- X }
- X }
- X return( new );
- X}
- X
- Xint
- Xdelete_depend( struct depend *dep )
- X{
- X free( dep );
- X return( 0 );
- X}
- X
- Xvoid
- Xdelete_dependlist( struct List *list )
- X{
- X for_list( list, delete_depend );
- X NewList( list );
- X}
- X
- Xstruct command *
- Xnew_command( char *cmd )
- X{
- X long size;
- X struct command *new = NULL;
- X if( cmd && *cmd ) {
- X size = sizeof(struct command) + strlen( cmd );
- X new = (struct command *)malloc( size );
- X if( new ) {
- X if( *cmd == '-' ) {
- X new->flags = CF_IGNORE;
- X cmd++;
- X }
- X else if( *cmd == '@' ) {
- X new->flags = CF_NOECHO;
- X cmd++;
- X }
- X else new->flags = 0;
- X strcpy( new->cmd, cmd );
- X }
- X }
- X return( new );
- X}
- X
- Xint
- Xdelete_command( struct command *cmd )
- X{
- X free( cmd );
- X return( 0 );
- X}
- X
- Xvoid
- Xdelete_commandlist( struct List *list )
- X{
- X for_list( list, delete_command );
- X NewList( list );
- X}
- X
- Xstruct suffixrule *
- Xfind_suffixrule( char *dep_suf, char *tar_suf )
- X{
- X struct suffixrule *sr = NULL;
- X
- X for( struct suffixrule *ln = Global.suffixlist.lh_Head; ln->node.ln_Succ;
- X ln = ln->node.ln_Succ ) {
- X if( !strcmp( dep_suf, ln->dep_suf ) &&
- X !strcmp( tar_suf, ln->tar_suf )) {
- X sr = ln;
- X break;
- X }
- X }
- X
- X return( sr );
- X}
- X
- Xstruct suffixrule *
- Xnew_suffixrule( char *dep_suf, char *tar_suf )
- X{
- X int found_flag = 0;
- X long size = sizeof(struct suffixrule);
- X struct suffixrule *new = find_suffixrule( dep_suf, tar_suf );
- X if( new ) found_flag = 1;
- X else new = (struct suffixrule *)malloc( size );
- X
- X if( new ) {
- X strcpy( new->tar_suf, tar_suf );
- X strcpy( new->dep_suf, dep_suf );
- X if( !found_flag ) AddTail( &Global.suffixlist, &new->node );
- X }
- X return( new );
- X}
- X
- Xint
- Xdelete_suffixrule( struct suffixrule *rule )
- X{
- X free( rule );
- X return( 0 );
- X}
- X
- Xvoid
- Xdelete_suffixlist( struct List *list )
- X{
- X for_list( list, delete_suffixrule );
- X}
- X
- Xstruct target *
- Xadd_suffix_targets( char *suf )
- X{
- X char *next, tar_suf[ 16 ], dep_suf[ 16 ];
- X struct target *ln, *first_targ = NULL;
- X
- X for( ln = (struct target *)Global.targetlist.lh_Head;
- X ln->node.ln_Succ; ln = ln->node.ln_Succ ) {
- X
- X next = ln->name;
- X *dep_suf = *tar_suf = (char)0;
- X
- X if( *next++ == '.' ) {
- X next = parse_strtok( tar_suf, next, sizeof(suf)-1, isnotsuf );
- X if( *next++ == '.' ) {
- X strcpy( dep_suf, tar_suf ); /* double-suffix */
- X next = parse_strtok( tar_suf, next, sizeof(suf)-1, isnotsuf );
- X }
- X }
- X if( !strcmp( suf, dep_suf) || !strcmp( suf, tar_suf )) {
- X /* transform a target rule into a suffix rule */
- X struct suffixrule *sr = new_suffixrule( dep_suf, tar_suf );
- X if( sr ) {
- X sr->targ = ln;
- X ln->flags |= TF_SUFFIX;
- X if( !first_targ ) first_targ = ln;
- X }
- X else return( NULL ); /* error */
- X }
- X }
- X
- X return( first_targ );
- X}
- END_OF_FILE
- if test 3984 -ne `wc -c <'depend.c'`; then
- echo shar: \"'depend.c'\" unpacked with wrong size!
- fi
- # end of 'depend.c'
- fi
- if test -f 'depend.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'depend.h'\"
- else
- echo shar: Extracting \"'depend.h'\" \(2635 characters\)
- sed "s/^X//" >'depend.h' <<'END_OF_FILE'
- X/* depend.h
- X *
- X */
- X
- X#include <time.h>
- X
- X#ifndef MAXLINE
- X#define MAXLINE 1024
- X#endif
- X
- X#ifndef MAXSUFFIX
- X#define MAXSUFFIX 16
- X#endif
- X
- X#ifndef MAX_MACRONAME
- X#define MAX_MACRONAME 256
- X#endif
- X
- X#ifndef FNCALLS
- X#define FNCALLS 1
- X#endif
- X
- Xstruct target {
- X struct Node node;
- X struct List dependlist;
- X struct List commandlist;
- X struct List *alternate; /* if not OWNER of the commandlist */
- X time_t mtime;
- X long flags;
- X int line_number;
- X char name[ 2 ];
- X};
- X
- X/* target flags */
- X#define TF_ADDED 0x00000001
- X#define TF_OWNER 0x00000002
- X#define TF_SUFFIX 0x00000004
- X#define TF_BUILTIN 0x00000008
- X#define TF_MADE 0x80000000
- X
- Xstruct depend {
- X struct Node node;
- X char name[ 2 ];
- X};
- X
- Xstruct command {
- X struct Node node;
- X long flags;
- X char cmd[ 2 ];
- X};
- X
- X#define CF_IGNORE 0x00000001
- X#define CF_NOECHO 0x00000002
- X
- Xstruct suffixrule {
- X struct Node node;
- X char tar_suf[ MAXSUFFIX ];
- X char dep_suf[ MAXSUFFIX ];
- X struct target *targ;
- X};
- X
- Xstruct macro {
- X struct Node node;
- X long flags;
- X char *name; /* dynamic */
- X char *expansion; /* dynamic */
- X};
- X
- Xstruct fncall {
- X char *name;
- X int (*call)(struct macro *, char *);
- X};
- X
- X/* macro flags */
- X#define MF_EXPANDED 0x00000001
- X#define MF_SIMPLE 0x00000002
- X#define MF_ADDED 0x80000000
- X
- Xint getline( char *buf, int sz, FILE *in );
- X
- Xstruct target *find_target( char *targetname );
- Xstruct target *new_target( char *targetname );
- Xint delete_target( struct target *targ );
- Xvoid delete_targetlist( struct List *list );
- X
- Xstruct depend *new_depend( char *dependname );
- Xint delete_depend( struct depend *dep );
- Xvoid delete_dependlist( struct List *list );
- X
- Xstruct command *new_command( char *cmd );
- Xint delete_command( struct command *cmd );
- Xvoid delete_commandlist( struct List *list );
- X
- Xstruct suffixrule *new_suffixrule( char *dep_suf, char *tar_suf );
- Xint delete_suffixrule( struct suffixrule *rule );
- Xvoid delete_suffixlist( struct List *list );
- Xstruct target *add_suffix_targets( char *suf );
- X
- Xstruct target *find_macro( char *macroname );
- Xstruct macro *new_macro( char *name, char *expansion );
- Xstruct macro *set_macro( char *name, char *expansion );
- Xvoid set_target_macros( char *tarname, char *depname );
- Xint delete_macro( struct macro *mac );
- Xvoid delete_macrolist( struct List *list );
- X
- Xstruct fncall *find_fncall( char *name );
- Xvoid shift_string_left( char *string, int shift );
- Xint expand_macros( char *dest, char *src, int maxlen );
- X
- Xvoid dump_all( void );
- X
- Xstruct target *process_targetline( char *line, struct List *cmdlist,
- X int bulitin_flag );
- Xstruct macro *process_macroline( char *line );
- X
- Xtime_t nowtime( void );
- Xvoid touch( const char *filename );
- X
- Xint recipe( const char *goalname, struct List *cmdlist );
- END_OF_FILE
- if test 2635 -ne `wc -c <'depend.h'`; then
- echo shar: \"'depend.h'\" unpacked with wrong size!
- fi
- # end of 'depend.h'
- fi
- if test -f 'dumprules.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'dumprules.c'\"
- else
- echo shar: Extracting \"'dumprules.c'\" \(1933 characters\)
- sed "s/^X//" >'dumprules.c' <<'END_OF_FILE'
- X/* dumprules.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include "make.h"
- X#include "depend.h"
- X
- X
- Xvoid
- Xdump_macros( struct List *mlist )
- X{
- X struct macro *mac;
- X
- X debugprintf( 2,( "** Macros **\n" ));
- X
- X for( mac = mlist->lh_Head; mac->node.ln_Succ; mac =
- X mac->node.ln_Succ ) {
- X logprintf( "%s %s %s\n", mac->name,
- X (mac->flags & MF_SIMPLE) ? ":=" : "=", mac->expansion );
- X }
- X logprintf( "\n" );
- X}
- X
- Xstatic void
- Xdump_dependencies( struct List *dlist )
- X{
- X struct depend *dep;
- X
- X for( dep = dlist->lh_Head; dep->node.ln_Succ; dep =
- X dep->node.ln_Succ ) {
- X logprintf( " %s", dep->name );
- X }
- X logprintf( "\n" );
- X}
- X
- Xstatic void
- Xdump_commands( struct List *clist )
- X{
- X struct command *cmd;
- X
- X for( cmd = clist->lh_Head; cmd->node.ln_Succ; cmd =
- X cmd->node.ln_Succ ) {
- X logprintf( "\t%s\n", cmd->cmd );
- X }
- X}
- X
- Xvoid
- Xdump_targets( struct List *tlist )
- X{
- X struct target *targ;
- X
- X debugprintf( 2, ( "** Target Rules **\n" ));
- X
- X for( targ = tlist->lh_Head; targ->node.ln_Succ; targ =
- X targ->node.ln_Succ ) {
- X logprintf( "\n%s", targ->name );
- X if( targ->flags & TF_SUFFIX ) logprintf( " [SUFFIX]" );
- X if( targ->flags & TF_BUILTIN ) logprintf( " [BUILTIN]" );
- X logprintf( ":" );
- X dump_dependencies( &targ->dependlist );
- X if( targ->flags & TF_OWNER )
- X dump_commands( &targ->commandlist );
- X else
- X dump_commands( targ->alternate );
- X }
- X}
- X
- Xvoid
- Xdump_suffixrules( struct List *slist )
- X{
- X struct suffixrule *sr;
- X
- X debugprintf( 2, ( "** Suffix Rules **\n" ));
- X
- X for( sr = slist->lh_Head; sr->node.ln_Succ; sr =
- X sr->node.ln_Succ ) {
- X logprintf( "\n.%s.%s :\n", sr->dep_suf, sr->tar_suf );
- X if( sr->targ->flags & TF_OWNER )
- X dump_commands( &sr->targ->commandlist );
- X else
- X dump_commands( sr->targ->alternate );
- X }
- X}
- X
- X
- Xvoid
- Xdump_all( void )
- X{
- X debugprintf( 2, ("\n** Debug output for rules ** \n" ));
- X dump_macros( &Global.macrolist );
- X dump_suffixrules( &Global.suffixlist );
- X dump_targets( &Global.targetlist );
- X}
- END_OF_FILE
- if test 1933 -ne `wc -c <'dumprules.c'`; then
- echo shar: \"'dumprules.c'\" unpacked with wrong size!
- fi
- # end of 'dumprules.c'
- fi
- if test -f 'history' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'history'\"
- else
- echo shar: Extracting \"'history'\" \(2923 characters\)
- sed "s/^X//" >'history' <<'END_OF_FILE'
- X
- X HISTORY of CHANGES to the Make program
- X Copyright (c) 1991 by Ben Eng
- X
- XKEY:
- X -N New Feature
- X -B Bug Fix in program
- X -D Documentation
- X
- X---
- XJune 2, 1991
- X
- Xchanges from 0.5 to 0.6
- X
- X -B macro expansion in the arguments to eq() and neq() conditions
- X -B removed rawcon.c, so ^C breaks should work better
- X
- X -N added $(words text) function call
- X -N added $(word n,text) function call
- X -N added $(firstword text) function call
- X -N added stubs for function calls that are not implemented
- X
- X -N changed static storage to dynamic storage for reading the Makefile
- X -N the maximum line length can now be set as a parameter
- X -N function calls are now able to accept arguments up to MaxLine
- X in length
- X -N added ``pragma'' directive to specify command line arguments
- X for the Make program within the Makefile
- X
- X -B removed enforcer hits; all were read-hits :-).
- X
- X---
- XMay 31, 1991
- X
- Xchanges from 0.4 to 0.5
- X
- X -N conditionals
- X -B command line macro assignments are performed twice; once before
- X Makefile is read, and once before the Makefile is run
- X
- X---
- XMay 30, 1991
- X
- Xchanges from 0.3 to 0.4
- X
- X -B allow commas to be escaped with a backslash in function calls
- X -B $(subst) changed to work with in any position; not just suffixes
- X
- X -N added $(filter pattern,text) function call
- X -N added $(filter-out pattern,text) function call
- X -N added $(wildcard pattern) function call
- X -N added $(basename names) function call
- X -N added $(addsuffix suffix,names) function call
- X -N added $(addprefix prefix,names) function call
- X
- X
- X---
- XMay 29, 1991 distributed 0.3 on ab20.larc.nasa.gov [128.155.23.64]
- X
- Xchanges from 0.2 to 0.3
- X
- X -D fixed the previous dates in the HISTORY file
- X -D fixed the documentation on simple variables
- X
- X -B added better error detection for infinitely
- X expanded macros.
- X
- X -B fixed the macro expansion for variables that expand
- X to a value containing the character `$'
- X
- X -B fixed the macro expansion for unknown variables
- X
- X -N added function call capabilities to the macro
- X expansion facility
- X -N added $(strip string) function call
- X -N added $(findstring find,in) function call
- X -N added $(subst from,to,text) function call
- X
- X
- X---
- XMay 28, 1991 distributed 0.2 on Bix
- X
- Xchanges from 0.1 to 0.2
- X
- X -B added a check for out of memory in ben/scdir.c
- X
- X -N parsing of command line macro=value definitions
- X
- X---
- XMay 27, 1991 distributed 0.1 on Tardis BBS
- X
- Xchanges from 0.0 to 0.1
- X
- X -N recursive macro expansions within variable name
- X references are now supported; ie. ${hello$(idx)}.
- X
- X -B multiple expansions of the same variable was
- X incorrectly trapped as an infinitely recursive
- X macro expansion.
- X
- X -B standard rules are now allowed to be defined as
- X builtin rules, without being selected as the
- X default target (goal) to be made.
- X
- X -B when the Makefile does not end in an empty line
- X the last rule is thrown out.
- X
- X---
- XMay 26, 1991 limited local distribution
- X
- Xinitial release 0.0
- X
- X---
- END_OF_FILE
- if test 2923 -ne `wc -c <'history'`; then
- echo shar: \"'history'\" unpacked with wrong size!
- fi
- # end of 'history'
- fi
- if test ! -d 'include' ; then
- echo shar: Creating directory \"'include'\"
- mkdir 'include'
- fi
- if test -f 'include/scdir.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'include/scdir.h'\"
- else
- echo shar: Extracting \"'include/scdir.h'\" \(161 characters\)
- sed "s/^X//" >'include/scdir.h' <<'END_OF_FILE'
- X/* scdir.h
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X */
- X
- Xvoid scdir_abort( void ); /* atexit( scdir_abort ); */
- Xchar *scdir( const char * wild );
- X
- END_OF_FILE
- if test 161 -ne `wc -c <'include/scdir.h'`; then
- echo shar: \"'include/scdir.h'\" unpacked with wrong size!
- fi
- # end of 'include/scdir.h'
- fi
- if test -f 'known-bugs' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'known-bugs'\"
- else
- echo shar: Extracting \"'known-bugs'\" \(739 characters\)
- sed "s/^X//" >'known-bugs' <<'END_OF_FILE'
- X
- XJune 2, 1991
- X
- X--
- XUsing the backslash character as a character escape
- X
- XExample: $(fncall \,arg1, ... )
- XExample: echo "price = \$100"
- X
- XAvoid using the backslash to escape characters. I haven't any clue what
- Xthe backslash will generally do, but in particular places the backslash can
- Xbe used to escape the meaning of the next character. Although that
- Xprobably works fine in the particular context, the escaped character is not
- Xbe remapped properly to the character itself, so the backslash character
- Xwill hang around, as if it were literal. $$ should be used instead of \$.
- X
- X--
- XA function call that returns an ERROR will not cause the Makefile to be
- Xaborted. Execution will continue as if the function call returned an
- Xempty string.
- X
- X--
- END_OF_FILE
- if test 739 -ne `wc -c <'known-bugs'`; then
- echo shar: \"'known-bugs'\" unpacked with wrong size!
- fi
- # end of 'known-bugs'
- fi
- if test -f 'lists.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'lists.c'\"
- else
- echo shar: Extracting \"'lists.c'\" \(503 characters\)
- sed "s/^X//" >'lists.c' <<'END_OF_FILE'
- X/* lists.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <clib/exec_protos.h>
- X
- X#include "make.h"
- X
- X
- Xstruct void *
- Xfor_list( struct List *list, long (*node_fn)(void *))
- X{
- X struct Node *ln, *succ;
- X
- X for( ln = list->lh_Head; ln->ln_Succ; ln = succ ) {
- X succ = ln->ln_Succ;
- X if( (*node_fn)( ln )) return( ln );
- X }
- X return( NULL );
- X}
- X
- Xvoid
- Xattach_list( struct List *newlist, struct List *oldlist )
- X{
- X struct Node *ln;
- X
- X while( ln = RemHead( oldlist ))
- X AddTail( newlist, ln );
- X}
- X
- END_OF_FILE
- if test 503 -ne `wc -c <'lists.c'`; then
- echo shar: \"'lists.c'\" unpacked with wrong size!
- fi
- # end of 'lists.c'
- fi
- if test -f 'log.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'log.c'\"
- else
- echo shar: Extracting \"'log.c'\" \(894 characters\)
- sed "s/^X//" >'log.c' <<'END_OF_FILE'
- X/* log.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include "make.h"
- X
- X#define LOGFILE "make.log"
- X
- Xint
- Xopen_logfile( void )
- X{
- X if( !Global.logfile ) {
- X Global.logfile = fopen( LOGFILE, "a" );
- X if( !Global.logfile ) return( 1 );
- X }
- X return( 0 );
- X}
- X
- Xvoid
- Xclose_logfile( void )
- X{
- X if( Global.logfile ) fclose( Global.logfile );
- X}
- X
- Xvoid
- Xlogfile( char *string )
- X{
- X FILE *out;
- X
- X if( Param.log && !Global.logfile ) open_logfile();
- X
- X out = ( Param.log ) ? Global.logfile : stdout;
- X if( Param.log || Param.verbosity ) {
- X fputs( string, out );
- X fputc( '\n', out );
- X fflush( out );
- X }
- X}
- X
- Xvoid
- Xlogprintf( const char *fmt, ... )
- X{
- X va_list argptr;
- X FILE *out;
- X
- X va_start( argptr, fmt );
- X if( Param.log && !Global.logfile ) open_logfile();
- X
- X out = ( Param.log ) ? Global.logfile : stdout;
- X if( Param.log || Param.verbosity ) {
- X vfprintf( out, fmt, argptr );
- X }
- X va_end( argptr );
- X}
- END_OF_FILE
- if test 894 -ne `wc -c <'log.c'`; then
- echo shar: \"'log.c'\" unpacked with wrong size!
- fi
- # end of 'log.c'
- fi
- if test -f 'macro.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'macro.c'\"
- else
- echo shar: Extracting \"'macro.c'\" \(3534 characters\)
- sed "s/^X//" >'macro.c' <<'END_OF_FILE'
- X/* macro.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X * USER DEFINABLE variables
- X *
- X * $x = the variable x
- X * $(var) = the variable var
- X * ${var} = the same variable var
- X *
- X * INTERNAL AUTOMATIC variables (not for user definitions)
- X *
- X * $$ = $
- X * $@ = target filename
- X * $* = basename of target
- X * $< = dependent filename
- X * $^ = all dependents of target newer than target (not-imp)
- X * $% = dependent member of the target archive (not-imp)
- X * $? = all dependents of the target archive (not-imp)
- X */
- X
- X#include <clib/exec_protos.h>
- X
- X#include "make.h"
- X#include "depend.h"
- X
- X/* internal function used to find an existing variable */
- Xstruct target *
- Xfind_macro( char *macroname )
- X{
- X struct macro *mac = NULL;
- X
- X for( struct macro *ln = Global.macrolist.lh_Head; ln->node.ln_Succ;
- X ln = ln->node.ln_Succ ) {
- X if( !strcmp( macroname, ln->name )) {
- X mac = ln;
- X break;
- X }
- X }
- X
- X return( mac );
- X}
- X
- X/* internal allocation function */
- Xstruct macro *
- Xnew_macro( char *name, char *expansion )
- X{
- X long size = sizeof(struct macro);
- X struct macro *new = (struct macro *)calloc( size, 1 );
- X if( new ) {
- X if( name )
- X if( !(new->name = strdup( name ))) goto death;
- X if( expansion )
- X if( !(new->expansion = strdup( expansion ))) goto death;
- X new->flags = 0;
- X }
- X return( new );
- Xdeath:
- X if( new ) {
- X if( new->name ) free( new->name );
- X if( new->expansion ) free( new->expansion );
- X free( new );
- X }
- X return( NULL );
- X}
- X
- X/* internal deallocation function */
- Xint
- Xdelete_macro( struct macro *mac )
- X{
- X if( mac->name ) free( mac->name );
- X if( mac->expansion ) free( mac->expansion );
- X free( mac );
- X return( 0 );
- X}
- X
- X/* perform a variable assignment
- X * this is the entry point from outside
- X * a NULL or null string will delete the variable
- X */
- Xstruct macro *
- Xset_macro( char *name, char *expansion )
- X{
- X struct macro *mac = NULL;
- X int create_flag = (expansion && !isemptyline( expansion ));
- X
- X if( mac = find_macro( name )) {
- X if( create_flag ) {
- X if( mac->expansion ) free( mac->expansion );
- X mac->expansion = strdup( expansion );
- X }
- X else {
- X Remove( &mac->node );
- X delete_macro( mac );
- X mac = NULL;
- X }
- X }
- X else
- X if( create_flag ) mac = new_macro( name, expansion );
- X
- X if( mac && !(mac->flags & MF_ADDED )) {
- X mac->flags |= MF_ADDED;
- X AddTail( &Global.macrolist, &mac->node );
- X }
- X return( mac );
- X}
- X
- X/* Set's the automatic variables $@ $* and $< */
- Xvoid
- Xset_target_macros( char *tarname, char *depname )
- X{
- X struct macro *mac;
- X
- X if( tarname && *tarname ) {
- X char *dupname = strdup( tarname );
- X char *next;
- X if( dupname ) { /* try the more efficient way first */
- X next = strrchr( dupname, '.' );
- X if( next ) *next = (char)0; /* remove the extension */
- X mac = set_macro( "*", dupname );
- X free( dupname );
- X }
- X else {
- X mac = set_macro( "*", tarname );
- X next = strrchr( mac->name, '.' );
- X if( next ) *next = (char)0; /* remove the extension */
- X }
- X }
- X else mac = set_macro( "*", NULL );
- X mac = set_macro( "@", tarname );
- X mac = set_macro( "<", depname );
- X}
- X
- Xvoid
- Xdelete_macrolist( struct List *list )
- X{
- X for_list( list, delete_macro );
- X NewList( list );
- X}
- X
- X/* set a variable by expanding all macros in its value */
- Xstruct macro *
- Xset_simplemacro( char *name, char *value )
- X{
- X char *expansion = NULL;
- X struct macro *mac = NULL;
- X
- X expansion = (char *)malloc( Param.MaxLine );
- X if( !expansion ) goto death;
- X
- X if( expand_macros( expansion, value, Param.MaxLine )) goto death;
- X if( mac = set_macro( name, expansion )) {
- X mac->flags |= MF_SIMPLE;
- X }
- Xdeath:
- X if( expansion ) free( expansion );
- X return( mac );
- X}
- END_OF_FILE
- if test 3534 -ne `wc -c <'macro.c'`; then
- echo shar: \"'macro.c'\" unpacked with wrong size!
- fi
- # end of 'macro.c'
- fi
- if test -f 'main.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'main.c'\"
- else
- echo shar: Extracting \"'main.c'\" \(4324 characters\)
- sed "s/^X//" >'main.c' <<'END_OF_FILE'
- X/* main.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <ctype.h>
- X
- X#include <exec/exec.h>
- X#include <exec/execbase.h>
- X
- X#include <intuition/intuitionbase.h>
- X#include <graphics/gfxbase.h>
- X
- X#include <clib/exec_protos.h>
- X#include <clib/dos_protos.h>
- X
- Xextern struct GfxBase *GfxBase;
- Xextern struct IntuitionBase *IntuitionBase;
- X
- X#include "make.h"
- X#include "depend.h"
- X
- X/* Globals */
- Xstruct globals Global = {
- X NULL, /* me */
- X NULL, /* logfile */
- X
- X {
- X (struct Node *)&Global.targetlist.lh_Tail, /* lh_Head */
- X (struct Node *)NULL, /* lh_Tail */
- X (struct Node *)&Global.targetlist.lh_Head, /* lh_TailPred */
- X (UBYTE)NT_USER,
- X (UBYTE)0
- X }, /* targetlist */
- X {
- X (struct Node *)&Global.suffixlist.lh_Tail, /* lh_Head */
- X (struct Node *)NULL, /* lh_Tail */
- X (struct Node *)&Global.suffixlist.lh_Head, /* lh_TailPred */
- X (UBYTE)NT_USER,
- X (UBYTE)0
- X }, /* suffixlist */
- X {
- X (struct Node *)&Global.macrolist.lh_Tail, /* lh_Head */
- X (struct Node *)NULL, /* lh_Tail */
- X (struct Node *)&Global.macrolist.lh_Head, /* lh_TailPred */
- X (UBYTE)NT_USER,
- X (UBYTE)0
- X }, /* macrolist */
- X 0 /* recursion level */
- X};
- X
- Xstatic int
- Xopen_libraries( void )
- X{
- X#ifndef _DCC
- X if( !( IntuitionBase = OpenLibrary( "intuition.library", 33 ))) {
- X return( 1 );
- X }
- X if( !( GfxBase = OpenLibrary( "graphics.library", 33 ))) {
- X return( 1 );
- X }
- X#endif
- X return( 0 );
- X}
- X
- Xstatic void
- Xclose_libraries( void )
- X{
- X#ifndef _DCC
- X if( IntuitionBase )
- X CloseLibrary( IntuitionBase );
- X
- X if( GfxBase )
- X CloseLibrary( GfxBase );
- X#endif
- X}
- X
- Xstatic int
- Xnew_globals( struct globals *globptr )
- X{
- X globptr->me = (struct Process *) FindTask( NULL ); /* find this task */
- X return( 0 );
- Xdeath:
- X printf( "problem initializing globals\n" );
- X return( 1 );
- X}
- X
- Xstatic int
- Xdelete_globals( struct globals *globptr )
- X{
- X memset( globptr, 0, sizeof(struct globals));
- X
- X /* just allow exit() to take care of free()ing all of our
- X * allocations, because I don't feel like doing it right now
- X */
- X NewList( &globptr->targetlist );
- X NewList( &globptr->suffixlist );
- X NewList( &globptr->macrolist );
- X}
- X
- X
- Xstatic void
- Xdie( void )
- X{
- X delete_params();
- X
- X close_logfile();
- X
- X delete_globals( &Global );
- X close_libraries();
- X}
- X
- Xstatic int
- Xinit( void )
- X{
- X if( open_libraries()) goto death;
- X if( new_globals( &Global )) goto death;
- X
- X return( 0 );
- Xdeath:
- X return( 1 );
- X}
- X
- Xstatic long
- Xdo_cl_macro( struct string_node *one )
- X{
- X long retval;
- X int made;
- X
- X if( strchr( one->data, '=' )) {
- X logprintf( "\t%s\n", one->data );
- X process_macroline( one->data );
- X Remove( &one->node );
- X delete_snode( one );
- X }
- X return( 0 );
- X}
- X
- Xstatic long
- Xrun_one( struct string_node *one )
- X{
- X long retval;
- X int made;
- X
- X debugprintf( 2, ("\n** run_one Make %s **\n", one->data ));
- X retval = (long) make_filename( one->data, &made );
- X if( !retval && !made ) {
- X logprintf( "\"%s\" is up to date\n", one->data );
- X }
- X return( retval );
- X}
- X
- Xstatic void
- Xrun_it( void )
- X{
- X long retval;
- X int made;
- X
- X if( Param.filelist.lh_Head->ln_Succ )
- X (void)for_list( &Param.filelist, do_cl_macro );
- X if( Param.filelist.lh_Head->ln_Succ ) {
- X (void)for_list( &Param.filelist, run_one );
- X }
- X else {
- X struct target *first_goal;
- X for( first_goal = (struct target *)Global.targetlist.lh_Head;
- X first_goal->node.ln_Succ;
- X first_goal = first_goal->node.ln_Succ ) {
- X if( !(first_goal->flags & (TF_SUFFIX|TF_BUILTIN ))) break;
- X }
- X if( first_goal->node.ln_Succ ) {
- X debugprintf( 2, ("\n** first_goal Make %s **\n",
- X first_goal->name ));
- X retval = make_filename( first_goal->name, &made );
- X if( !retval && !made ) {
- X logprintf( "\"%s\" is up to date\n", first_goal->name );
- X }
- X }
- X }
- X logprintf( "\tMake done.\n" );
- X}
- X
- Xint
- Xmain( int argc, char *argv[] )
- X{
- X if( GfxBase->LibNode.lib_Version < 36L ) {
- X printf( "This program requires Amiga OS 2.0\n" );
- X return( 20 );
- X }
- X
- X atexit( die ); /* add die() to normal exit procedure */
- X
- X if( parse_parameters( argc, argv )) goto bailout;
- X
- X logprintf( "%s\n", version_string+7 );
- X logprintf( "%s\n", copyright_string );
- X
- X if( init() ) goto bailout;
- X if( init_builtins()) goto bailout;
- X
- X if( Param.filelist.lh_Head->ln_Succ )
- X (void)for_list( &Param.filelist, do_cl_macro );
- X
- X if( input_makefile( Param.makefile, 0 )) goto bailout;
- X if( Param.print_database ) dump_all();
- X else run_it();
- X
- X return( 0 );
- X
- Xbailout:
- X /* die(); is called by atexit */
- X return( 20 );
- X}
- X
- END_OF_FILE
- if test 4324 -ne `wc -c <'main.c'`; then
- echo shar: \"'main.c'\" unpacked with wrong size!
- fi
- # end of 'main.c'
- fi
- if test -f 'make.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'make.h'\"
- else
- echo shar: Extracting \"'make.h'\" \(3099 characters\)
- sed "s/^X//" >'make.h' <<'END_OF_FILE'
- X#include <exec/nodes.h>
- X#include <exec/lists.h>
- X#include <intuition/intuition.h>
- X#include <dos/dos.h>
- X#include <dos/dosextens.h>
- X#include <stdio.h>
- X#include <stdlib.h>
- X#include <string.h>
- X#include <stdarg.h>
- X
- X#ifndef MAXPATHNAME
- X#define MAXPATHNAME 108
- X#endif
- X
- Xstruct parameters {
- X struct List filelist;
- X int MaxLine; /* maximum line length */
- X int verbosity; /* 0 = silent */
- X int log;
- X int debug;
- X int touch_mode;
- X int all_mode;
- X int no_builtins;
- X int pretend_mode;
- X int print_database;
- X char *makefile;
- X};
- X
- Xstruct globals {
- X struct Process *me;
- X FILE *logfile;
- X
- X struct List targetlist; /* target rules */
- X struct List suffixlist; /* suffix rules */
- X struct List macrolist; /* macros */
- X
- X int recursion_level;
- X};
- X
- Xstruct string_node {
- X struct Node node;
- X char data[2];
- X};
- X
- X#define min(a,b) (((a) < (b)) ? (a) : (b))
- X#define max(a,b) (((a) > (b)) ? (a) : (b))
- X
- X
- Xextern struct parameters Param;
- Xextern struct globals Global;
- Xextern char version_string[];
- Xextern char copyright_string[];
- X
- Xextern void NewList( struct List * );
- Xextern char *basename( const char * );
- X
- X#define debugprintf(l,x) \
- X if( Param.debug && Param.verbosity >= (l)) logprintf x ;
- X
- Xint parse_parameters( int argc, char *argv[] );
- Xvoid delete_params( void );
- X
- Xstruct string_node *new_snode( const char *str );
- Xstruct string_node *renew_snode( const struct string_node *old, const char *str );
- Xstruct string_node *delete_snode( struct string_node *old );
- Xvoid delete_slist( struct List *list );
- X
- Xstruct void *for_list( struct List *list, long (*node_fn)(void *));
- Xvoid attach_list( struct List *newlist, struct List *oldlist );
- X
- Xint help( void );
- X
- X/*
- Xint prompt( BPTR tty, const char *str );
- Xvoid tty_gotoxy( BPTR tty, int x, int y );
- Xvoid tty_put( BPTR tty, char *str, long outsize );
- Xvoid tty_puts( BPTR tty, char *str );
- Xvoid tty_printf( BPTR tty, const char *fmt, ... );
- Xvoid tty_clear( BPTR tty );
- Xvoid tty_clear_eol( BPTR tty );
- Xvoid tty_open_line( BPTR tty );
- Xvoid tty_normal( BPTR tty );
- Xvoid tty_bold( BPTR tty );
- Xvoid tty_underline( BPTR tty );
- Xvoid tty_backspace( BPTR tty );
- Xvoid tty_scroll_up( BPTR tty, int lines );
- Xvoid tty_scroll_down( BPTR tty, int lines );
- X
- Xint tty_getchar( void );
- Xint hit_a_key( void );
- Xvoid statusline( const char *s );
- Xint get_string( char *buf, int mlen );
- Xint get_number( char *buf, int mlen );
- Xint get_valid_string( char *buf, int mlen, int (*validate)());
- X*/
- X
- Xint open_logfile( void );
- Xvoid close_logfile( void );
- Xvoid logfile( char *string );
- Xvoid logprintf( const char *fmt, ... );
- X
- Xlong doCommand( char *command, BPTR other );
- Xlong xsystem( char *cmd );
- X
- Xint input_makefile( const char *makefile, int builtin_flag );
- Xint make_filename( const char *goalname, int *made );
- Xint get_directive_state( void );
- X
- Xchar *find_token( char *line, int tok );
- Xint isemptyline( char *line );
- Xchar *parse_strtok( char *dest, char *source, int len, int (*isdelim)( int ));
- Xchar *parse_str( char *dest, char *source, int len);
- Xint count_args(unsigned char *string);
- Xchar *find_word( char *string, int word );
- Xvoid strip_trailspace( char *line );
- Xint isnotsuf( int ch );
- X
- Xint init_builtins( void );
- END_OF_FILE
- if test 3099 -ne `wc -c <'make.h'`; then
- echo shar: \"'make.h'\" unpacked with wrong size!
- fi
- # end of 'make.h'
- fi
- if test -f 'param.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'param.c'\"
- else
- echo shar: Extracting \"'param.c'\" \(3663 characters\)
- sed "s/^X//" >'param.c' <<'END_OF_FILE'
- X/* param.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <ctype.h>
- X#include <scdir.h>
- X
- X#include <clib/exec_protos.h>
- X
- X#include "make.h"
- X
- Xstruct parameters Param = {
- X {
- X (struct Node *)&Param.filelist.lh_Tail, /* lh_Head */
- X (struct Node *)NULL, /* lh_Tail */
- X (struct Node *)&Param.filelist.lh_Head, /* lh_TailPred */
- X (UBYTE)NT_USER,
- X (UBYTE)0
- X }, /* filelist */
- X 1024, /* MaxLine */
- X 1, /* verbosity */
- X 0, /* log */
- X 0, /* debug */
- X 0, /* touch mode */
- X 0, /* all mode */
- X 0, /* no builtins */
- X 0, /* pretend mode */
- X 0, /* print database */
- X NULL /* makefile */
- X};
- X
- Xconst char *usage_string =
- X "Usage: make -abdhnpt -v# +m# -fmakefile var=value wildcards...";
- X
- Xconst char *help_lines[] = {
- X "-a\t" "make all dependents regardless of modification time",
- X "-b\t" "do not use builtin rules",
- X "-d\t" "debug mode (enable printf)",
- X "+m#\t" "sets the maximum line length to # (minimum = 1024)",
- X "-n\t" "prints commands to be executed, but do not execute them",
- X "-p\t" "prints the database, but do not run",
- X "-t\t" "make targets up to date by touching (commands not executed)",
- X "-v#\t" "set verbose level to #; 0=silent",
- X "-fmakefile\t" "specify the makefile to run",
- X "var=value\t" "assigns the value to a variable",
- X "wildcards\t" "specify specific targets to make",
- X NULL
- X};
- X
- Xvoid
- Xusage( void )
- X{
- X puts( version_string+7 );
- X puts( usage_string );
- X}
- X
- Xint
- Xhelp( void )
- X{
- X int i = 0;
- X char *helpline;
- X
- X usage();
- X puts( copyright_string );
- X puts( "" );
- X while( helpline = help_lines[ i++ ] ) {
- X puts( helpline );
- X }
- X
- X return( 0 );
- X}
- X
- Xstatic int
- Xexpand_wildcard( const char *wild )
- X{
- X struct string_node *sptr = NULL;
- X char *fn;
- X
- X while( fn = scdir( wild )) {
- X if( sptr = new_snode( fn )) {
- X AddTail( &Param.filelist, &sptr->node );
- X }
- X else return( 1 );
- X }
- X return( 0 );
- X}
- X
- Xint
- Xparse_parameters( int argc, char *argv[] )
- X{
- X char *arg;
- X
- X for( int i = 1; i < argc; i++ ) {
- X if( !(arg = argv[ i ] )) break;
- X switch( *arg ) {
- X case '-':
- X switch( *++arg ) {
- X default:
- X case '?':
- X usage();
- X goto death;
- X case 'V':
- X puts( version_string + 7);
- X puts( copyright_string );
- X goto death;
- X case 'a':
- X Param.all_mode = 1;
- X break;
- X case 'b':
- X Param.no_builtins = 1;
- X break;
- X case 'd':
- X Param.debug = 1;
- X break;
- X case 'f':
- X if( Param.makefile ) {
- X puts( "only one -f argument is allowed" );
- X goto death;
- X }
- X else {
- X if( *++arg ) Param.makefile = strdup( arg );
- X else if( ++i < argc ) {
- X arg = argv[ i ];
- X if( *arg ) Param.makefile = strdup( arg );
- X }
- X }
- X break;
- X case 'h':
- X help();
- X goto death;
- X case 'n':
- X Param.pretend_mode = 1;
- X break;
- X case 'p':
- X Param.print_database = 1;
- X case 't':
- X Param.touch_mode = 1;
- X break;
- X case 'v':
- X Param.verbosity = atoi( ++arg );
- X break;
- X }
- X break;
- X case '+':
- X switch( *++arg ) {
- X case 'l':
- X Param.log = (Param.log) ? 0 : 1;
- X break;
- X case 'm':
- X {
- X int maxline = atoi( ++arg );
- X Param.MaxLine = max( Param.MaxLine, maxline);
- X }
- X }
- X break;
- X case '?':
- X usage();
- X goto death;
- X default: /* a filename */
- X if( scdir( arg ) ) {
- X scdir_abort();
- X if( expand_wildcard( arg )) goto death;
- X }
- X else {
- X struct string_node *sptr = new_snode( arg );
- X if( sptr ) {
- X AddTail( &Param.filelist, &sptr->node );
- X }
- X }
- X break;
- X }
- X }
- X if( !Param.makefile ) Param.makefile = strdup( "Makefile" );
- X
- X return( 0 );
- Xdeath:
- X return( 1 );
- X}
- X
- Xvoid
- Xdelete_params( void )
- X{
- X if( Param.makefile ) {
- X free( Param.makefile );
- X Param.makefile = NULL;
- X }
- X /* free Param */
- X delete_slist( &Param.filelist );
- X NewList( &Param.filelist );
- X}
- END_OF_FILE
- if test 3663 -ne `wc -c <'param.c'`; then
- echo shar: \"'param.c'\" unpacked with wrong size!
- fi
- # end of 'param.c'
- fi
- if test -f 'parsing.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'parsing.c'\"
- else
- echo shar: Extracting \"'parsing.c'\" \(2427 characters\)
- sed "s/^X//" >'parsing.c' <<'END_OF_FILE'
- X/* Parsing.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <string.h>
- X#include <ctype.h>
- X
- X/* Parse the first word from the source string into the dest string
- X *
- X * return: pointer to next whitespace past parsed argument
- X */
- X
- Xchar *
- Xparse_strtok( char *dest, char *source, int len, int (*isdelim)( int ))
- X{
- X register char *s, *d;
- X int i = 0;
- X
- X s = source;
- X d=dest;
- X while( i < len && *s ) {
- X if( (*isdelim)( *s )) break;
- X *d++ = *s++;
- X i++;
- X }
- X *d=(char)0;
- X return s;
- X}
- X
- X
- Xstatic int
- Xiswhite( int ch )
- X{
- X return( isspace( ch )); /* macro */
- X}
- X
- X/* Parse the first word from the source string into the dest string
- X *
- X * return: pointer to next whitespace past parsed argument
- X */
- Xchar *
- Xparse_str( char *dest, char *source, int len )
- X{
- X while( isspace( *source )) source++; /* skip whitespaces */
- X return( parse_strtok( dest, source, len - 1, iswhite ));
- X}
- X
- X/* Counts the number of words in the string */
- Xint
- Xcount_args( unsigned char *string )
- X{
- X int count, sflag, prev;
- X register unsigned char *a = string;
- X
- X prev = 1;
- X count = 0;
- X for( ; *a; a++ ) {
- X sflag = isspace( *a );
- X if( !sflag && prev ) count++;
- X prev = sflag;
- X }
- X return count;
- X}
- X
- X/* finds the position of a particular word in a string */
- X/* the first word is numbered 1 */
- X/* find_word( string, count_args( string )) == last_word */
- Xchar *
- Xfind_word( char *string, int word )
- X{
- X int count, sflag, prev;
- X register char *a = string;
- X
- X prev = 1;
- X count = 0;
- X for( ; *a; a++ ) {
- X sflag = isspace( *a );
- X if( !sflag && prev ) if( ++count == word ) return( a );
- X prev = sflag;
- X }
- X return( NULL ); /* not found */
- X}
- X
- Xvoid
- Xstrip_trailspace( char *line )
- X{
- X char *cptr;
- X
- X cptr = line + strlen( line ) - 1;
- X
- X while( cptr >= line && isspace( *cptr )) {
- X *cptr-- = (char)0;
- X }
- X}
- X
- Xint
- Xisnotsuf( int ch )
- X{
- X if( !ch || isspace( ch ) || ch == '.' ) return( 1 );
- X return( 0 );
- X}
- X
- Xint
- Xisemptyline( char *line )
- X{
- X while( *line ) {
- X if( !isspace( *line )) return( 0 );
- X line++;
- X }
- X return( 1 );
- X}
- X
- X/* locate the next instance of a token that is not escaped by a backslash
- X */
- Xchar *
- Xfind_token( char *line, int tok )
- X{
- X char *delim = strchr( line, tok );
- X while( delim && *(delim-1) == '\\' ) {
- X delim = strchr( delim + 1, tok );
- X }
- X return( delim );
- X}
- X
- Xvoid
- Xshift_string_left( char *string, int shift )
- X{
- X register char *d, *s;
- X char *end = string + strlen( string );
- X
- X d = string;
- X s = string + shift;
- X while( s <= end ) {
- X *d++ = *s++;
- X }
- X}
- X
- END_OF_FILE
- if test 2427 -ne `wc -c <'parsing.c'`; then
- echo shar: \"'parsing.c'\" unpacked with wrong size!
- fi
- # end of 'parsing.c'
- fi
- if test -f 'rawcon.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rawcon.c'\"
- else
- echo shar: Extracting \"'rawcon.c'\" \(2784 characters\)
- sed "s/^X//" >'rawcon.c' <<'END_OF_FILE'
- X/* rawcon.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <exec/types.h>
- X#include <exec/nodes.h>
- X#include <exec/memory.h>
- X#include <exec/tasks.h>
- X#include <exec/ports.h>
- X#include <exec/execbase.h>
- X#include <libraries/dos.h>
- X#include <libraries/dosextens.h>
- X#include <intuition/intuitionbase.h>
- X#include <intuition/intuition.h>
- X#include <workbench/startup.h>
- X
- X#include <clib/exec_protos.h>
- X#include <clib/dos_protos.h>
- X
- X#include "make.h"
- X
- Xvoid
- XSetRawMode( long flag )
- X{
- X struct Process *process;
- X struct MsgPort *conport;
- X struct MsgPort *replyport;
- X struct StandardPacket *pkt;
- X
- X if( !(process = Global.me )) return; /* find this task */
- X /* msgport for CON: */
- X conport = (struct MsgPort *) process->pr_ConsoleTask;
- X
- X replyport=&process->pr_MsgPort;
- X
- X pkt=(struct StandardPacket *) malloc(sizeof(struct StandardPacket));
- X
- X pkt->sp_Msg.mn_Node.ln_Name=(char *) &pkt->sp_Pkt;
- X pkt->sp_Pkt.dp_Port=replyport;
- X pkt->sp_Pkt.dp_Type=994L; /* set raw mode */
- X pkt->sp_Pkt.dp_Link=&pkt->sp_Msg;
- X pkt->sp_Pkt.dp_Arg1=flag; /* TRUE for on, FALSE for off */
- X
- X PutMsg(conport,&pkt->sp_Msg);
- X WaitPort(replyport);
- X Remove((struct Node *)&pkt->sp_Msg);
- X
- X free(pkt);
- X}
- X
- X/* findwindow.c - utility routine to find window of a CLI. */
- Xstruct Window *
- XFindWindow( BPTR file )
- X{
- X extern struct DosLibrary *DOSBase;
- X struct Window *win;
- X struct Process *proc;
- X struct CommandLineInterface *cli;
- X struct InfoData *id;
- X struct StandardPacket *pkt;
- X struct FileHandle *fh;
- X long ret1,ret2;
- X
- X if (id=(struct InfoData *)
- X AllocMem(sizeof(struct InfoData),MEMF_PUBLIC|MEMF_CLEAR)) {
- X if (pkt=(struct StandardPacket *)
- X AllocMem(sizeof(struct StandardPacket),MEMF_PUBLIC|MEMF_CLEAR)) {
- X proc=(struct Process *) FindTask(NULL);
- X if (cli=(struct CommandLineInterface *) (proc->pr_CLI<<2)) {
- X ret1=cli->cli_ReturnCode;
- X ret2=cli->cli_Result2;
- X if (IsInteractive(file)) {
- X pkt->sp_Msg.mn_Node.ln_Name=(char *) &(pkt->sp_Pkt);
- X pkt->sp_Pkt.dp_Link=&(pkt->sp_Msg);
- X pkt->sp_Pkt.dp_Port=&(proc->pr_MsgPort);
- X pkt->sp_Pkt.dp_Type=ACTION_DISK_INFO;
- X pkt->sp_Pkt.dp_Arg1=((ULONG) id)>>2;
- X fh=(struct FileHandle *) (file<<2);
- X PutMsg(fh->fh_Type,(struct Message *) pkt);
- X WaitPort(&(proc->pr_MsgPort));
- X GetMsg(&(proc->pr_MsgPort));
- X win=(struct Window *) id->id_VolumeNode;
- X }
- X cli->cli_Result2=ret2;
- X cli->cli_ReturnCode=ret1;
- X }
- X FreeMem(pkt,sizeof(struct StandardPacket));
- X }
- X FreeMem(id,sizeof(struct InfoData));
- X }
- X return(win);
- X}
- X
- END_OF_FILE
- if test 2784 -ne `wc -c <'rawcon.c'`; then
- echo shar: \"'rawcon.c'\" unpacked with wrong size!
- fi
- # end of 'rawcon.c'
- fi
- if test -f 'readme' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'readme'\"
- else
- echo shar: Extracting \"'readme'\" \(5098 characters\)
- sed "s/^X//" >'readme' <<'END_OF_FILE'
- X
- X Readme For The Make Utility
- X
- X Copyright (c) 1991 by Ben Eng
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X
- X
- XHOW TO CONTACT ME
- X
- X Ben Eng
- X 150 Beverley St. Apt #1L
- X Toronto, Ontario
- X M5T 1Y6
- X CANADA
- X
- X telephone: (416)-979-8761
- X
- X e-mail: ben@contact.uucp or uunet!mnetor!becker!contact!ben
- X BIX: jetpen
- X
- X
- XMANIFEST
- X
- X README - This file
- X COPYING - The GNU General Public License
- X bmake - The binary executable for the Amiga running OS 2.0
- X bmake.doc - The documentation
- X less - utility for reading text files under Amiga OS 2.0
- X
- X Makefile \
- X builtin.c \
- X dumprules.c |
- X log.c |
- X lists.c |
- X param.c |
- X snode.c |
- X make.c |
- X read.c |__ Source code to the Make program
- X touch.c |
- X input.c |
- X expand.c |
- X parsing.c |
- X depend.c |
- X fncall.c |
- X main.c |
- X macro.c |
- X version.c /
- X recipe.c /
- X
- X makefile \
- X builtin.c \
- X depend.c |
- X depend.h |
- X dumprules.c |
- X input.c |
- X lists.c |
- X log.c |
- X macro.c |
- X main.c |__ Source code to the Make program
- X make.c |
- X make.h |
- X param.c |
- X parsing.c |
- X rawcon.c |
- X recipe.c |
- X snode.c |
- X touch.c |
- X tty.c /
- X version.c /
- X
- X ben/basename.c \
- X ben/makefile \__ Some files necessary to make ben.lib
- X ben/scdir.c /
- X ben/system.c /
- X
- X include/scdir.h -- header file for the scdir routines
- X
- X
- XABOUT THE PROGRAM
- X
- XThis program requires Amiga OS 2.0 or higher to run. Run the program with
- Xthe argument `?' to see its usage, or ``-h'' to get more descriptive help
- Xon acceptable command line arguments.
- X
- XBecause the program was compiled with DICE 2.06.22, the heap memory
- Xroutines directly perform an AllocMem() from the system memory pool. The
- XMake program performs many small allocations and deallocations, so it is
- Xpossible for memory to become fragmented. Hopefully, sophisticated heap
- Xmemory routines will appear in the standard library to reduce memory
- Xfragmentation. I haven't noticed any problems with fragmentation though.
- X
- XThe environment variable ENV:system can be set to ``yes'' if you wish the
- Xcommand execution to use the Amiga OS 2.0 System() call. If ENV:system is
- Xset to ``no'', the Amiga OS Execute() call is used instead. The latter is
- Xdesirable if you are still running with a shell that does not support the
- X2.0 conventions (WShell 1.2 falls under this category).
- X
- XCommand line arguments to Make may not be grouped together; ``-a -n'' is
- Xcompletely different from ``-an'' (which doesn't exist).
- X
- XThe present version of the Make program is incomplete and possibly
- Xbug-ridden. The documentation and functionality is incomplete, and
- Xstill requires much work to be done.
- X
- XAs far as the author is concerned, because this software and documentation
- Xis distributed free of charge, he is not obligated to provide any support
- Xor updates. However, the complete source code is provided, along with
- Xenough information to construct an executable from it. The author would be
- Xvery appreciative of any comments, bug reports, and bug fixes that might be
- Xprovided via paper mail and electronic mail (the addresses are provided
- Xabove).
- X
- XIf there is something broken, first try to find an updated version of this
- Xprogram. If the bug still exists in the most recent version of the
- Xprogram, please report it so that it can be fixed. If you have fixed the
- Xbug yourself, please provide me with the fixes so that they can be
- Xincorporated into the next update.
- X
- XIf you actually use this program, I would like to know about it. If I find
- Xthat nobody uses it then I will not distribute future updates to it. I
- Xwrite programs that are useful to me, and I tend to distribute them if they
- Xare useful to others. I will only know that my programs are useful to
- Xothers if they let me know that they use them. Besides, I enjoy reading
- Xwell-written mail.
- X
- XFeel free to send me things of little or great value, if it suits your
- Xfancy. Although this software is free (with respect to freedom) and no
- Xfees are charged for its private use, I am not at all opposed to receiving
- Xtokens of material wealth.
- X
- X[ And why do I have an 'If' in almost every sentence? I think that I have
- Xbeen programming too long today... :-) ]
- X
- X -Ben
- X
- END_OF_FILE
- if test 5098 -ne `wc -c <'readme'`; then
- echo shar: \"'readme'\" unpacked with wrong size!
- fi
- # end of 'readme'
- fi
- if test -f 'recipe.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'recipe.c'\"
- else
- echo shar: Extracting \"'recipe.c'\" \(1546 characters\)
- sed "s/^X//" >'recipe.c' <<'END_OF_FILE'
- X/* recipe.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <clib/exec_protos.h>
- X#include <clib/dos_protos.h>
- X
- X#include <string.h>
- X#include <ctype.h>
- X
- X#include "make.h"
- X#include "depend.h"
- X
- X/* execute the command List to make a target */
- Xint
- Xrecipe( const char *goalname, struct List *cmdlist )
- X{
- X char cd_string[ 10 ];
- X struct command *cmd;
- X char *expansion = NULL;
- X char *next;
- X int retval = 0;
- X
- X if( !cmdlist ) return( 0 ); /* no command list */
- X
- X if( Param.touch_mode ) {
- X logprintf( "\ttouch(%s)\n", goalname );
- X if( !Param.pretend_mode ) touch( goalname );
- X return( 0 );
- X }
- X
- X expansion = (char *)malloc( Param.MaxLine );
- X
- X for( cmd = (struct command *) cmdlist->lh_Head; cmd->node.ln_Succ;
- X cmd = cmd->node.ln_Succ ) {
- X if( next = cmd->cmd )
- X while( isspace( *next )) next++;
- X if( next && *next ) {
- X if( expand_macros( expansion, next, Param.MaxLine )) {
- X logprintf( "Error expanding macros on commandline:\n"
- X "\t%s\n", next );
- X break;
- X };
- X if( !(cmd->flags & CF_NOECHO ) || Param.debug )
- X logprintf( "\t%s\n", expansion );
- X parse_str( cd_string, expansion, 10 );
- X if( !strcmp( cd_string, "cd" )) {
- X logprintf( "the \"cd\" command does not work\n" );
- X break;
- X }
- X retval = (Param.pretend_mode ) ? 0 :xsystem( expansion );
- X if( retval ) {
- X char *s = (cmd->flags & CF_IGNORE ) ? "(Ignored)" : "" ;
- X logprintf( "command returned error %d %s\n", retval, s );
- X if( !(cmd->flags & CF_IGNORE )) break;
- X }
- X }
- X }
- X if( expansion ) free( expansion );
- X return( retval );
- X}
- END_OF_FILE
- if test 1546 -ne `wc -c <'recipe.c'`; then
- echo shar: \"'recipe.c'\" unpacked with wrong size!
- fi
- # end of 'recipe.c'
- fi
- if test -f 'snode.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'snode.c'\"
- else
- echo shar: Extracting \"'snode.c'\" \(1059 characters\)
- sed "s/^X//" >'snode.c' <<'END_OF_FILE'
- X/* snode.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X */
- X
- X#include <ctype.h>
- X
- X#include "make.h"
- X
- Xstruct string_node *
- Xnew_snode( const char *str )
- X{
- X struct string_node *new;
- X
- X if( new = malloc( sizeof(*new) + strlen( str ) )) {
- X strcpy( new->data, str );
- X new->node.ln_Name = new->data;
- X new->node.ln_Type = (UBYTE)NT_USER;
- X new->node.ln_Pri = 0; /* Priority, for sorting */
- X }
- X return( new );
- X}
- X
- Xstruct string_node *
- Xrenew_snode( const struct string_node *old, const char *str )
- X{
- X struct string_node *new;
- X
- X if( new = realloc( old, sizeof(*new) + strlen( str ) )) {
- X strcpy( new->data, str );
- X new->node.ln_Name = new->data;
- X }
- X return( new );
- X}
- X
- Xstruct string_node *
- Xdelete_snode( struct string_node *old )
- X{
- X free( old );
- X return( NULL );
- X}
- X
- Xvoid
- Xdelete_slist( struct List *list )
- X{
- X for_list( list, delete_snode );
- X NewList( list );
- X}
- X
- X#ifdef DEBUG
- Xint
- Xprint_snode( struct string_node *old )
- X{
- X printf( "snode: %s\n", old->data );
- X return( 0 );
- X}
- X
- Xvoid
- Xprint_slist( struct list *list )
- X{
- X for_list( list, print_snode );
- X}
- X#endif
- END_OF_FILE
- if test 1059 -ne `wc -c <'snode.c'`; then
- echo shar: \"'snode.c'\" unpacked with wrong size!
- fi
- # end of 'snode.c'
- fi
- if test -f 'touch.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'touch.c'\"
- else
- echo shar: Extracting \"'touch.c'\" \(2250 characters\)
- sed "s/^X//" >'touch.c' <<'END_OF_FILE'
- X/* touch.c
- X * (c) Copyright 1991 by Ben Eng, All Rights Reserved
- X *
- X * Update the modification time of a file to the present time.
- X */
- X
- X#include <exec/memory.h>
- X
- X#include <clib/exec_protos.h>
- X#include <clib/dos_protos.h>
- X
- Xextern struct MsgPort *CreatePort( UBYTE *name, long pri );
- Xextern void DeletePort( struct MsgPort *io );
- X
- X#include <time.h>
- X
- X#include "make.h"
- X
- X/* return the current time */
- Xtime_t
- Xnowtime( void )
- X{
- X struct DateStamp t;
- X time_t outtime = 0L;
- X
- X DateStamp( &t );
- X outtime = t.ds_Tick/TICKS_PER_SECOND + 60*t.ds_Minute + 86400*t.ds_Days;
- X return( outtime );
- X}
- X
- Xstatic long
- Xdos_packet( struct MsgPort *port, long type,
- Xlong arg1, long arg2, long arg3, long arg4, long arg5, long arg6, long arg7 )
- X{
- X struct StandardPacket *sp;
- X struct MsgPort *rp;
- X long ret;
- X
- X if( !( rp = CreatePort( NULL, 0L ))) return( 1 );
- X if( !( sp = AllocMem( sizeof(*sp), MEMF_PUBLIC|MEMF_CLEAR))) {
- X DeletePort( rp );
- X return( 1 );
- X }
- X sp->sp_Msg.mn_Node.ln_Name = (char *)&sp->sp_Pkt;
- X sp->sp_Pkt.dp_Link = &sp->sp_Msg;
- X sp->sp_Pkt.dp_Port = rp;
- X sp->sp_Pkt.dp_Type = type;
- X sp->sp_Pkt.dp_Arg1 = arg1;
- X sp->sp_Pkt.dp_Arg2 = arg2;
- X sp->sp_Pkt.dp_Arg3 = arg3;
- X sp->sp_Pkt.dp_Arg4 = arg4;
- X sp->sp_Pkt.dp_Arg5 = arg5;
- X sp->sp_Pkt.dp_Arg6 = arg6;
- X sp->sp_Pkt.dp_Arg7 = arg7;
- X PutMsg( port, &sp->sp_Msg );
- X WaitPort( rp );
- X GetMsg( rp );
- X ret = sp->sp_Pkt.dp_Res1;
- X FreeMem( (void *)sp, sizeof(*sp) );
- X DeletePort(rp);
- X return( ret );
- X}
- X
- X/* update the modification time of a file */
- Xvoid
- Xtouch( const char *filename )
- X{
- X struct MsgPort *task = NULL;
- X BPTR lock = (BPTR)0L;
- X BPTR plock = (BPTR)0L;
- X char *bcplstring = NULL;
- X struct DateStamp dateStamp;
- X
- X if( !( bcplstring = (char *)AllocMem(64L, MEMF_PUBLIC))) goto death;
- X if( !( task = (struct MsgPort *)DeviceProc( filename ))) goto death;
- X if( !( lock = Lock( filename, SHARED_LOCK ))) goto death;
- X plock = ParentDir( lock );
- X UnLock( lock ); lock = NULL;
- X
- X /* Strip pathnames first */
- X strcpy( bcplstring + 1, basename( filename ));
- X *bcplstring = (char)strlen(bcplstring + 1);
- X
- X dos_packet( task, ACTION_SET_DATE, NULL, plock, (long)bcplstring >> 2,
- X (long) DateStamp( &dateStamp ), 0L, 0L, 0L);
- X
- Xdeath:
- X if( lock) UnLock( lock );
- X if( plock) UnLock( plock );
- X FreeMem((void *) bcplstring, 64L );
- X}
- END_OF_FILE
- if test 2250 -ne `wc -c <'touch.c'`; then
- echo shar: \"'touch.c'\" unpacked with wrong size!
- fi
- # end of 'touch.c'
- fi
- if test -f 'version.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'version.c'\"
- else
- echo shar: Extracting \"'version.c'\" \(155 characters\)
- sed "s/^X//" >'version.c' <<'END_OF_FILE'
- Xchar version_string[] = "\0$VER: Make 0.6 " __DATE__ " " __TIME__;
- Xchar copyright_string[] = "Copyright " "\xa9" " 1991 by Ben Eng, All Rights Reserved";
- X
- END_OF_FILE
- if test 155 -ne `wc -c <'version.c'`; then
- echo shar: \"'version.c'\" unpacked with wrong size!
- fi
- # end of 'version.c'
- fi
- if test -f 'wishlist' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'wishlist'\"
- else
- echo shar: Extracting \"'wishlist'\" \(861 characters\)
- sed "s/^X//" >'wishlist' <<'END_OF_FILE'
- XWISHLIST
- X
- XHere are some features which I would like to implement in the future.
- X
- X- :: rules to supply alternate rules for targets
- X- + command prefix to force the execution of lines
- X- force the execution of lines containing $(MAKE) or ${MAKE}
- X- the ``cd'' command
- X- the $^ automatic variable
- X- .DEFAULT .IGNORE .PHONY .PRECIOUS .SILENT
- X- pattern rules (eg., %.o: %.c) for greater flexibility
- X- static pattern rules
- X- replace all suffix rules with pattern rules
- X- the ability to apply rules to the contents of archives
- X and link libraries
- X- vpath and VPATH search paths for dependencies
- X
- X- and as many of the functions listed in Chapter 9 of the manual to
- X GNU Make as humanly possible
- X
- X- -W command line argument to run Make with a ``what if'' scenario
- X- parallel remote execution of compiles
- X
- X- the ability to pass variables between nested executions of Make
- X
- X
- END_OF_FILE
- if test 861 -ne `wc -c <'wishlist'`; then
- echo shar: \"'wishlist'\" unpacked with wrong size!
- fi
- # end of 'wishlist'
- fi
- echo shar: End of archive 1 \(of 3\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.misc.
-